////////////////////////////////////////////////////////////////////////////////

#ifndef _INTERSECTOR_H_
#include "intersector.h"
#endif

#ifndef _CIRCLECIRCLEINTERSECTOR_H_
#include "circlecircleintersector.h"
#endif


#ifndef _CIRCLEPOLYGONINTERSECTOR_H_
#include "circlepolygonintersector.h"
#endif

#ifndef _POLYGONCIRCLEINTERSECTOR_H_
#include "polygoncircleintersector.h"
#endif

#ifndef _SHAPE_H_
#include "shape.h"
#endif

#ifndef _MATHFUNCTIONS_H_
#include "mathfunctions.h"
#endif

#include <cassert>

////////////////////////////////////////////////////////////////////////////////


CircleCircleIntersector* Intersector::m_CircleCircleIntersector = NULL;
CirclePolygonIntersector* Intersector::m_CirclePolygonIntersector = NULL;
PolygonCircleIntersector* Intersector::m_PolygonCircleIntersector = NULL;


////////////////////////////////////////////////////////////////////////////////


Intersector& Intersector::GetCircleCircleIntersector()
{
    if (!m_CircleCircleIntersector)
        m_CircleCircleIntersector = new CircleCircleIntersector();

    return *m_CircleCircleIntersector;
}


////////////////////////////////////////////////////////////////////////////////


Intersector& Intersector::GetCirclePolygonIntersector()
{
    if (!m_CirclePolygonIntersector)
        m_CirclePolygonIntersector = new CirclePolygonIntersector();

    return *m_CirclePolygonIntersector;
}


////////////////////////////////////////////////////////////////////////////////


Intersector& Intersector::GetPolygonCircleIntersector()
{
    if (!m_PolygonCircleIntersector)
        m_PolygonCircleIntersector = new PolygonCircleIntersector();

    return *m_PolygonCircleIntersector;
}


////////////////////////////////////////////////////////////////////////////////


bool Intersector::WasIntersection() const
{
    return m_WasIntersection;
}


////////////////////////////////////////////////////////////////////////////////


const PE::Direction Intersector::GetNormal() const
{
    assert(m_WasIntersection);
    return m_Normal;
}


////////////////////////////////////////////////////////////////////////////////
